const nodemailer = require("nodemailer");

const sendMail=(email)=>{
    let mailtransporter = nodemailer.createTransport({
        service:"qq",
        port: 465,
        secure: true, // true for 465, false for other ports
        auth: {
          user: "2691750681@qq.com", // generated ethereal user
          pass: "zwjlqrdovljzdgec", // generated ethereal password
        }
    })

    let options ={
        from: "2691750681@qq.com", // sender address
        to: email, // list of receivers
        subject: "Hello ✔", // Subject line
        text: "Hello world?", // plain text body
        html: "<b>Hello world?</b>", // html body
    }

    return new Promise((resolve, reject) => {
        mailtransporter.sendMail(options,(err,info)=>{
            if(err){
                reject(new Error(err))
            }else{
                resolve({
                    code:200,
                    info
                })
            }
        })
    })
}

module.exports={
    sendMail
}